This is the analysis script to prepare the data to run analyses for the project “Anxiety, depression and trauma symptom change during the COVID-19 pandemic: retrospective versus objective assessment” - Young et al (2020)
Script written by K L Purves, K N Thompson, C Huebel and M Davies. Email: kirstin.purves@kcl.ac.uk, katie.thompson@kcl.ac.uk, christopher.1.huebel@kcl.ac.uk, molly.davies@kcl.ac.uk
#Set up
Clear global environment
Retrieve the current date to use it for file endings to not overwrite files when one exports files
#Packages Install packages (if they are not available in your version of R)
Load packages
Registered S3 method overwritten by 'pryr':
method from
print.bytes Rcpp
For best results, restart R session and update pander using devtools:: or remotes::install_github('rapporter/pander')
Attaching package: 'polycor'
The following object is masked from 'package:psych':
polyserial
corrplot 0.84 loaded
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✓ ggplot2 3.3.2 ✓ purrr 0.3.4
✓ tibble 3.0.4 ✓ dplyr 1.0.2
✓ tidyr 1.1.2 ✓ stringr 1.4.0
✓ readr 1.3.1 ✓ forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x ggplot2::%+%() masks psych::%+%()
x ggplot2::alpha() masks psych::alpha()
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
x tibble::view() masks summarytools::view()
FunctionLib/lm_forest.R FunctionLib/lm_formula.R
value ? ?
visible FALSE FALSE
FunctionLib/lm_output.R FunctionLib/raincloud.R
value ? ?
visible FALSE FALSE
Define colours for plotting this are the standard coping colours
Choose in this chunk which palette to use 04.07.2020 - Default to 2 colour COPING palette
Set up ggplot theme for the plots
[1] 32970 643
[1] "gad.sum_score_prepan" "pcl.sum_score_prepan"
[3] "phq.sum_score_prepan" "phq.sum_score_8items_prepan"
[5] "ocir.sum_score_prepan" "gad.sum_score_base"
[7] "gad.sum_score_retro" "pcl.sum_score_base"
[9] "pcl.sum_score_retro" "phq.sum_score_base"
[11] "phq.sum_score_8items_base" "phq.sum_score_retro"
[13] "phq.sum_score_8items_retro" "ocir.sum_score_base"
[15] "ocir.sum_score_retro"
[1] "phq.sum_score_prepan" "phq.sum_score_base" "phq.sum_score_retro"
[1] "gad.sum_score_prepan" "gad.sum_score_base" "gad.sum_score_retro"
[1] "ocir.sum_score_prepan" "ocir.sum_score_base" "ocir.sum_score_retro"
[1] "pcl.sum_score_prepan" "pcl.sum_score_base" "pcl.sum_score_retro"
[1] "phq.diff_score_retro_prepan" "phq.diff_score_base_prepan"
[3] "phq.diff_score_base_retro" "gad.diff_score_retro_prepan"
[5] "gad.diff_score_base_prepan" "gad.diff_score_base_retro"
[7] "pcl.diff_score_base_prepan" "ocir.diff_score_retro_prepan"
[9] "ocir.diff_score_base_prepan" "ocir.diff_score_base_retro"
[1] "phq.diff_score_retro_prepan" "phq.diff_score_base_prepan"
[3] "phq.diff_score_base_retro"
[1] "gad.diff_score_retro_prepan" "gad.diff_score_base_prepan"
[3] "gad.diff_score_base_retro"
[1] "ocir.diff_score_retro_prepan" "ocir.diff_score_base_prepan"
[3] "ocir.diff_score_base_retro"
#ANALYSIS PLAN 1. Calculate mean change per disorder group i. Disorders (9) a. Rank the disorders by the size of the change ii. Sex iii. Age (13; RAMP; potentially collapse above 65 depending on group sizes) iv. Ethnicity groups (5; White European, Black (British), Asian, Arab, Mixed)
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Table for knitting gad sum score summary table
| Change | Variable | Min | Max | Mean | Median | SD | Skew | Kurtosis |
|---|---|---|---|---|---|---|---|---|
| No change | Base | 0 | 21 | 2.710983 | 1.0 | 4.484467 | 2.1561885 | 4.3402823 |
| No change | Prepan | 0 | 21 | 8.254932 | 7.0 | 6.202852 | 0.4754996 | -0.9032129 |
| No change | Retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| Worsening | Base | 0 | 21 | 8.765028 | 7.0 | 5.709022 | 0.5131785 | -0.8169438 |
| Worsening | Prepan | 0 | 21 | 9.403875 | 8.0 | 5.859497 | 0.3389671 | -0.9329372 |
| Worsening | Retro | 0 | 21 | 4.665087 | 4.0 | 4.285430 | 1.3714955 | 1.9190355 |
| Improvement | Base | 0 | 21 | 4.763024 | 3.0 | 4.812355 | 1.3705444 | 1.5963789 |
| Improvement | Prepan | 0 | 21 | 9.228041 | 8.0 | 5.817921 | 0.3295928 | -0.9032305 |
| Improvement | Retro | 0 | 21 | 8.331025 | 7.0 | 5.476874 | 0.5159221 | -0.5853808 |
| NA | Base | 0 | 21 | 5.634615 | 4.5 | 5.897919 | 1.0732787 | 0.2309806 |
| NA | Prepan | 0 | 21 | 10.000000 | 13.0 | 8.563488 | -0.0313927 | -1.9895986 |
| NA | Retro | Inf | -Inf | NaN | NA | NA | NA | NA |
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Table for knitting gad diff summary table
| Change | Variable | Min | Max | Mean | Median | SD | Skew | Kurtosis |
|---|---|---|---|---|---|---|---|---|
| No change | Base - prepan | -21 | 20 | -2.0498783 | -1 | 4.730325 | -0.4870231 | 1.5079948 |
| No change | Base - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| No change | Prepan - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| Worsening | Base - prepan | -18 | 21 | 0.9694803 | 1 | 5.309832 | -0.0145504 | 0.6007935 |
| Worsening | Base - retro | -21 | 21 | 4.1004112 | 3 | 4.313654 | 0.7678166 | 0.8615045 |
| Worsening | Prepan - retro | -21 | 18 | -3.5772884 | -3 | 5.108094 | -0.2892807 | 0.4412892 |
| Improvement | Base - prepan | -21 | 12 | -4.0760778 | -3 | 5.490428 | -0.2970813 | 0.1264514 |
| Improvement | Base - retro | -21 | 21 | -3.5632502 | -3 | 5.339678 | 0.4581556 | 2.0535711 |
| Improvement | Prepan - retro | -21 | 20 | 0.3536379 | 1 | 5.692678 | -0.1576467 | 0.8754152 |
| NA | Base - prepan | -9 | 6 | -1.5000000 | -2 | 5.431390 | 0.0468089 | -1.6798094 |
| NA | Base - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| NA | Prepan - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
makes this into percentages
Warning: Removed 59038 rows containing non-finite values (stat_count).
Warning: Removed 34515 rows containing non-finite values (stat_bin).
Warning: Removed 34515 rows containing non-finite values (stat_bin).
Warning: Removed 24523 rows containing non-finite values (stat_bin).
Warning: Removed 34515 rows containing non-finite values (stat_bin).
Warning: Removed 34515 rows containing non-finite values (stat_bin).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 34515 rows containing non-finite values (stat_ydensity).
Warning: Removed 34515 rows containing non-finite values (stat_summary).
Warning: Removed 34515 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 34515 rows containing non-finite values (stat_ydensity).
Warning: Removed 34515 rows containing non-finite values (stat_summary).
Warning: Removed 34515 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 34515 rows containing non-finite values (stat_ydensity).
Warning: Removed 34515 rows containing non-finite values (stat_summary).
Warning: Removed 34515 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 34515 rows containing non-finite values (stat_ydensity).
Warning: Removed 34515 rows containing non-finite values (stat_summary).
Warning: Removed 34515 rows containing missing values (geom_point).